﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CityProvince.ascx.cs" Inherits="Administrator_AdminControl_CityProvince" %>

<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>


<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
    <script type="text/javascript">
        function gridCitProvince_Command(sender, args) {
            var result = true;
            var strCommand = args.get_commandName();
            
            if (strCommand == "Delete") {
                result = confirm('Bạn có chắc muốn xóa dữ liệu không?');
                if (result == false) {
                    args.set_cancel(true);
                }
            }

            if (strCommand == "Update") {
//                var itemIndex = parseInt(args.get_commandArgument());
//                var item = masterTableView.get_dataItems()[itemIndex];
//                var strCode = item.findElement("GeneralCategory_Code").value;
//                alert(strCode);
            }

//            alert(strCommand);
             
            return result;
        }
        
    </script>
</telerik:RadScriptBlock>

<div class="dasboard" style="width:80%;float:left">
    <div class="staticTitle">Tỉnh thành phố</div>
    <div class="style-padding1">
        <table style="width:70%">
            <tr>
                <td>Mã</td>
                <td><asp:TextBox ID="txtCityProvinceCode" runat="server" 
                        ValidationGroup="validator"/></td>
            </tr>
            <tr>
                <td>Tên</td>
                <td><asp:TextBox ID="txtCityProvinceName" runat="server" Width="100%" />                    
                </td>
                <td style="padding:20px">
                    <asp:Button ID="btnSave" runat="server" Text="Lưu"
                       onclick="btnSave_Click" /></td>
            </tr>
            <tr>
                <td></td>
                <td><asp:TextBox ID="txtSearchCityProvinceName" runat="server" Width="100%" /></td>
                <td style="padding:20px"><asp:Button ID="btnSearch" runat="server" Text="Tìm kiếm" 
                        onclick="btnSearch_Click"/></td>
            </tr>
        </table>        
        <telerik:RadGrid runat="server" ID="gridCityProvince" GridLines="None" 
            AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
            OnDeleteCommand="gridCityProvince_DeleteCommand"
            onneeddatasource="gridCityProvince_NeedDataSource"
            onupdatecommand="gridCityProvince_UpdateCommand">
            <MasterTableView DataKeyNames="GeneralCategory_Id" 
                 nomasterrecordstext="Không có dữ liệu để hiển thị">                    
                <Columns>                    
                    <%--<telerik:GridBoundColumn DataField="GeneralCategory_Id" HeaderText="GeneralCategory_Id" Visible="false">
                    </telerik:GridBoundColumn>--%>                  
                    <telerik:GridBoundColumn DataField="GeneralCategory_Code" HeaderText="Mã tỉnh thành">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="GeneralCategory_Name" HeaderText="Tên tỉnh thành">                    
                    </telerik:GridBoundColumn>
                    <%--<telerik:GridBoundColumn DataField="GeneralCategory_Type" HeaderText="GeneralCategory_Type" Visible="false">
                    </telerik:GridBoundColumn>--%>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                        <ItemStyle CssClass="MyImageButton" />
                    </telerik:GridEditCommandColumn>                    
                    <telerik:GridButtonColumn ConfirmDialogType="RadWindow"
                        ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                        UniqueName="DeleteColumn">
                        <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                    </telerik:GridButtonColumn>
                </Columns>
            
             <EditFormSettings>
                    <EditColumn ButtonType="ImageButton" InsertText="Insert Order" UpdateText="Cập nhật"
                        UniqueName="EditCommandColumn1" CancelText="Hủy cập nhật">
                    </EditColumn>                  
             </EditFormSettings>
            </MasterTableView>

        <FilterMenu EnableImageSprites="False"></FilterMenu>
        <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>
        <ClientSettings>
               <ClientEvents OnCommand="gridCitProvince_Command" />               
        </ClientSettings>
        </telerik:RadGrid>

        <telerik:RadAjaxManager ID="ajaxmanagerCityProvince" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="gridCityProvince">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="gridCityProvince" LoadingPanelID="loadingpanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="btnSave">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="gridCityProvince" LoadingPanelID="loadingpanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="btnSearch">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="gridCityProvince" LoadingPanelID="loadingpanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="gridCityProvince" EventName="gridCityProvince_DeleteCommand">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="gridCityProvince" LoadingPanelID="loadingpanel1" />                    
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="gridCityProvince" EventName="gridCityProvince_CancelCommand">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="gridCityProvince" LoadingPanelID="loadingpanel1" />                    
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="gridCityProvince" EventName="gridCityProvince_UpdateCommand">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="gridCityProvince" LoadingPanelID="loadingpanel1" />
                    <telerik:AjaxUpdatedControl ControlID="lblScript" LoadingPanelID="loadingpanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel runat="server" ID="loadingpanel1" Skin="Office2007">
    </telerik:RadAjaxLoadingPanel>    
</div>